#include "stm32f10x.h"                  // Device header

extern uint16_t AD_Value[4];

void myDMA_Init(void)
{
	RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
	
	DMA_InitTypeDef myDMA_InitStructure;
	// 外设DMA设置
	myDMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&ADC1->DR;
	myDMA_InitStructure.DMA_PeripheralDataSize = DMA_MemoryDataSize_HalfWord;
	myDMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
	// 存储器DMA设置
	myDMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)AD_Value;
	myDMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
	myDMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
	// Others
	myDMA_InitStructure.DMA_Priority = DMA_Priority_Medium;
	myDMA_InitStructure.DMA_BufferSize = 4;
	myDMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
	myDMA_InitStructure.DMA_M2M = DMA_M2M_Disable;					// 启用硬件触发
	myDMA_InitStructure.DMA_Mode = DMA_Mode_Circular;				// 循环读取
	DMA_Init(DMA1_Channel1, &myDMA_InitStructure);					// 注意看引脚,ADC1只能说通道1
	
//	// 允许中断
//	DMA_ITConfig();
	DMA_Cmd(DMA1_Channel1, ENABLE);
}
